<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

</head>
<body>
<div id="root">
    <input type="text">
    <input onclick="fn()" type="button" value="点击添加名字">
    <p></p>
</div>
<script>
    let input = document.querySelector("input")
    let op = document.querySelector("p")

    function fn() {
        op.innerText = input.value

    }

</script>

</body>
</html>